Bandit Write-up Level 6

Posted by CLoveYC on April 8, 2024

Goal:

Using command to get the password which is stored in a file somewhere under the 'inhere' directory and has three properties:
1. human-readable,
2. 1033 bytes in size,
3. not executable.

Login command: ssh bandit5@bandit.labs.overthewire.org -p 2220

Password: lrIWWI6bB37kxfiCQZqUdOIYfr6eEeqR

My Solution:

In my opinion, the size property may be unique. So I consulted the man pages for both 'file' and 'find'. The parameter '-size' under the 'find' command caught my eye. By using the parameter 'find [file] -size number[cwbkMG]', you can specify a specific file with the exact size you want. After learning this, I used 'find inhere/* -size 1033c' and found that only one file met the specified conditions: 'inhere/maybehere07/.file2'. Then, we used 'cat inhere/maybehere07/.file2' and obtained the key.

While reading the introduction to the size parameter, I noticed that there are some interesting properties associated with it. First, the size is consistent with the results obtained from 'ls -l'. If you are interested in this, please refer to Reference-1. Another interesting property is that when you want to specify greater or less than a certain size, you add + or - before the number. For example: 'find / -size +1M' or 'find ~ -size -1055c'. You can even combine both: 'find . -size +10M -size -20M'.

The Key

P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU



References

https://man7.org/linux/man-pages/man1/find.1.html

https://www.cnblogs.com/rusking/p/7403160.html

https://linuxconfig.org/how-to-use-find-command-to-search-for-files-based-on-file-size